{% extends 'manage/base_manage.html' %}
{% load static %}
{% block title %}Web测试用例步骤{% endblock %}

{% block css %}
    <link rel="stylesheet" href="{% static 'css/web_test/web_step_manage.css' %}">
{% endblock %}

{% block content %}
    <div class="content">
        <div id="test_content">
            <div id="test_list">
                <a id="title_distance" href="{% url 'atp:apis_manage' %}">单一接口用例</a>
                <a id="title_distance" href="{% url 'atp:api_test_manage' %}">流程接口用例</a>
                <a id="title_distance" href="{% url 'atp:web_test_manage' %}">Web测试用例</a>
                <a id="title_distance" href="{% url 'atp:app_test_manage' %}">App测试用例</a>
            </div>
            <h3 id="add_test_name">Web用例步骤</h3>
            <a id="add_test" href="{% url 'atp:web_step_add' web_t_id %}">＋添加Web用例步骤</a>
            <form id="" method="post" action="">
                {% csrf_token %}
                <table class="table-striped" id="table_list">
                    <thead>
                    <tr id="tr_title">
                        <th id="table_title_length3">所属用例名称</th>
                        <th id="table_title_length3">步骤</th>
                        <th id="table_title_length3">定位方式</th>
                        <th id="table_title_length">控件元素</th>
                        <th id="table_title_length4">操作方法</th>
                        <th id="table_title_length4">测试数据</th>
                        <th id="table_title_length">验证数据</th>
                        <th id="table_title_length">测试结果</th>
                        <th id="table_title_length4">时间</th>
                        <th id="table_title_length">编辑</th>
                        <th id="table_title_length">删除</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for web_step in web_steps %}
                        {% if web_step.web_test.id == web_t_id %}
                            <tr id="tr_d">
                                <td>{{ web_step.web_test.web_t_name }}</td>
                                <td>{{ web_step.web_step }}</td>
                                <td>{{ web_step.web_find_method }}</td>
                                <td>{{ web_step.web_element }}</td>
                                <td>{{ web_step.web_opt_method }}</td>
                                <td>{{ web_step.web_test_data }}</td>
                                <td>{{ web_step.web_assert_data }}</td>
                                <td>{% if web_step.web_result == 0 %}
                                    <a style="color: red;text-decoration: none">{{ web_step.web_result }}</a>
                                {% elif web_step.web_result == 1 %}
                                    <a style="color: green;text-decoration: none">{{ web_step.web_result }}</a>
                                {% endif %}
                                </td>
                                <td>{{ web_step.create_time }}</td>
                                <td><a style="color:cadetblue "
                                       href="{% url 'atp:web_step_update' web_t_id web_step.id %}">编辑</a></td>
                                <td><a style="color: #cc0000" href="javascript:"
                                       onclick="confirm_delete({{ web_step.id }})">删除</a></td>
                            </tr>
                        {% endif %}
                    {% endfor %}
                    </tbody>
                </table>
            </form>
            <a class="Return" href="{% url 'atp:web_test_manage' %}">返回Web测试用例列表</a>
        </div>
    </div>
{% endblock %}

{% block js %}
    <script>
        function confirm_delete(web_s_id) {
            layer.open({
                title: "是否确认删除?",
                btn: ['确定', '取消'],
                yes: function () {
                    $.ajax({
                        url: "{% url 'atp:web_step_delete'  %}",
                        type: "GET",
                        dataType: "JSON",
                        data: {"web_s_id": web_s_id},
                        success: function (res) {
                            if (res.code === 200) {
                                layer.msg('删除成功');
                                setTimeout(function () {
                                    parent.location.reload();
                                }, 1000);
                            } else {
                                layer.msg('删除失败');
                                setTimeout(function () {
                                    parent.location.reload();
                                }, 1000);
                            }
                        }
                    })
                }
            })
        }
    </script>
{% endblock %}